/*
** commande.c for my_irc in /home/billey_b/projet/my_irc/my-irc-a
** 
** Made by Bastien Billey
** Login   <billey_b@epitech.net>
** 
** Started on  Tue Apr 17 13:05:32 2012 Bastien Billey
** Last update Tue Apr 17 13:05:33 2012 Bastien Billey
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "client.h"

void	serveur(t_client *client)
{
  parse_addr_and_port(client);
  sock_client = xsocket(AF_INET, SOCK_STREAM, 0);
  client->addr.sin_family = AF_INET;
  client->port = atoi(client->cmd.arg2);
  client->addr.sin_port = htons(client->port);
  client->cmd.arg1 = "10.11.44.1";
  client->addr.sin_addr.s_addr = inet_addr(client->cmd.arg1);
  xconnect(sock_client, (struct sockaddr *)&client->addr,
sizeof(client->addr));
  printf("conected !!!\n");
}

void	nickname(t_client *client)
{
  parse_addr_and_port(client);
  if (strlen(client->cmd.arg1) > 64)
      printf("Name to long choose a nickname < 64 char\n");
  else if (strlen(client->cmd.arg1) < 1)
    printf("Type /nick [NICKMNAME]\n");
  else
    {
      xsend(sock_client, client->cmd.buff, strlen(client->cmd.buff), 0);
    }
}

void	list(t_client * client)
{
  parse_addr_and_port(client);
  if (strlen(client->cmd.arg1) < 1)
    printf("list tout");
  else
    printf("list les chan contenant %s\n", client->cmd.arg1);
}

void	join(t_client *client)
{
  parse_addr_and_port(client);
  printf("join\n");
  if (strlen(client->cmd.arg1) < 1)
    printf("faut specifier le chan a join mon coco\n");
  else
    printf("ca va join %s\n", client->cmd.arg1);
}

void	part(t_client *client)
{
  parse_addr_and_port(client);
  printf("part\n");
  if (strlen(client->cmd.arg1) < 1)
    printf("faut dire d'ou tu veux partir\n");
  else
    printf("tu va partir de %s\n", client->cmd.arg1);
}
